package com.cskaoyan.market.service;


import com.cskaoyan.market.db.mapper.MarketOrderMapper;
import com.cskaoyan.market.vo.WxUserIndexVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class WxUserServiceImpl implements WxUserService{


    @Autowired
    MarketOrderMapper marketOrderMapper;

    @Override
    public WxUserIndexVo index(Integer userId) {
        WxUserIndexVo wxUserIndexVo = new WxUserIndexVo();
        List<Map<String ,Object>> list=marketOrderMapper.index(userId);

//        String[] stringsKey=new String[]{"unrecv","uncomment","unpaid","unship"};
//        String[] stringsValue=new String[]{"301","401","101","201"};

        for (Map<String, Object> map : list) {
            Integer status = (Integer) map.get("status");
            Long number = (Long) map.get("number");
            if (301==status){
                wxUserIndexVo.setUnrecv(number);
            }else if (401==status){
                wxUserIndexVo.setUncomment(number);
            }else if (101==status){
                wxUserIndexVo.setUnpaid(number);
            }else if (201==status){
                wxUserIndexVo.setUnship(number);
            }

        }
        return wxUserIndexVo;

    }
}
